package com.example.doufacedemo

import android.app.Application
import android.util.Log
import com.ocom.ocomdevicesdk.device.keybroad.KeybroadDevice
import com.ocom.ocomdevicesdk.device.keybroad.OnKeybroadListener
import com.ocom.ocomdevicesdk.utils.UsbChecker
import org.bytedeco.xhfacelite.global.xhfacelite

class MyApp : Application() {
    companion object {
        lateinit var sess: xhfacelite.XHF_SESS
        lateinit var mContext: Application
    }

    override fun onCreate() {
        super.onCreate()
        mContext = this
        UsbChecker.init(this)
//        8199, 20785
        var loadUsbKeybroad = UsbChecker.loadUsbKeybroad(8199, 20785 )
        if (loadUsbKeybroad ==0){
            KeybroadDevice.getInstance().initUsbDevice()
        }
        Log.i("main", " loadUsbKeybroad输出 = $loadUsbKeybroad")
        KeybroadDevice.getInstance().setOnKeybroadListener(object : OnKeybroadListener {
            override fun keyPress(p0: String?) {
                Log.i("main", " 输出 = $p0")
                KeybroadDevice.getInstance().sendMessageToUsbKeybroad("CAAC0202303132333435363738390000000000000000000000000000000000000000ACCA")

            }

            override fun originData(p0: ByteArray?) {
                Log.i("main", " 输出 = $p0")

            }

        })
        UsbPreUntil.init(this)
    }
}